package com.tm.controller;

import com.tm.entity.Product;
import com.tm.service.ProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by lichuan on 2022-09-19.
 */

@RestController
public class ProductController {

    static final Logger logger = LoggerFactory.getLogger(ProductController.class);
    @Autowired
    private ProductService productService;

    @PostMapping("saveProd")
    public Object saveProd(@RequestBody Product product){

        return productService.saveProd(product);
    }
    @PutMapping("updateProd")
    public Object updateProd(@RequestBody Product product){

        return productService.updateProd(product);
    }

    @PutMapping("delProd")
    public Object delProd(@RequestBody Product product){

        return productService.del(product);
    }

    @GetMapping("getProd")
    public Object getProd( Product product){

        return productService.getProd(product);
    }

    @GetMapping("getCeshi")
    public Object getCeshi(){

        return productService.getCeshi();
    }

    @GetMapping("getAggr")
    public Object getAggr(){
        logger.info("获取聚合函数1");
        logger.warn("获取聚合函数2");
        logger.error("获取聚合函数3");
        return productService.getAggr();
    }
}
